<h4 class="h4"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;修改试题信息</h4>
<form class="layui-form" action="comm/questionsedit.php" lay-filter="example" method="post" id="tj">
   
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px;">试题类型</label>
        <div class="layui-input-block">
            <select name="type" lay-filter="aihao">
                <option value="单选">单选</option>
                <option value="多选">多选</option>
                <option value="简答">简答</option>
                <option value="应用题">应用题</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" >难度</label>
        <div class="layui-input-block">
            <input type="number" name="difficulty" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">题干</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" name="stem"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px;">正确答案</label>
        <div class="layui-input-block">
            <input type="text" name="resourcesinfo" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">考点</label>
        <div class="layui-input-block">
            <input type="text" name="points" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>

    <input type="hidden" name="id" value="<?=$id?>">
    <input type="hidden" name="rid" value="<?=$row['rid']?>">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>
<script>
    $('#tj').on('submit', function () {
        console.log($(this).serializeArray())
        if (!$(this).serializeArray()[0].value) {
            layer.msg('试题类型不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[1].value) {
            layer.msg('难度不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[2].value) {
            layer.msg('题干不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[2].value) {
            layer.msg('正确答案不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[2].value) {
            layer.msg('考点不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (parseInt($(this).serializeArray()[1].value)<0||parseInt($(this).serializeArray()[1].value)>5) {
            layer.msg('难度必须是1~5!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        return  ;
    });

    layui.use('form', function () {
        var form = layui.form;
        form.val('example', {
            "difficulty": "<?=$row['difficulty']?>"
            , "type": "<?=$row['type']?>"
            , "stem": "<?=$row['stem']?>"
            , "points": "<?=$row['points']?>"
            , "resourcesinfo": "<?=$row['resourcesinfo']?>"
        })
    });

</script>